home *** CD-ROM | disk | FTP | other *** search
/ Erotic Games: Memory / Erotic Games: Memory.iso / mac / air_installers / AdobeAIR.exe / setup.swf / scripts / mx / controls / ToolTip.as < prev    next >
Text File  |  2009-02-12  |  6KB  |  198 lines

  1. package mx.controls
  2. {
  3.    import flash.display.DisplayObject;
  4.    import flash.text.TextFieldAutoSize;
  5.    import flash.text.TextFormat;
  6.    import mx.core.EdgeMetrics;
  7.    import mx.core.IFlexDisplayObject;
  8.    import mx.core.IFlexModuleFactory;
  9.    import mx.core.IFontContextComponent;
  10.    import mx.core.IRectangularBorder;
  11.    import mx.core.IToolTip;
  12.    import mx.core.IUITextField;
  13.    import mx.core.UIComponent;
  14.    import mx.core.UITextField;
  15.    import mx.core.mx_internal;
  16.    import mx.styles.ISimpleStyleClient;
  17.    
  18.    use namespace mx_internal;
  19.    
  20.    public class ToolTip extends UIComponent implements IToolTip, IFontContextComponent
  21.    {
  22.       
  23.       mx_internal static const VERSION:String = "3.0.0.0";
  24.       
  25.       public static var maxWidth:Number = 300;
  26.        
  27.       
  28.       private var textChanged:Boolean;
  29.       
  30.       private var _text:String;
  31.       
  32.       protected var textField:IUITextField;
  33.       
  34.       mx_internal var border:IFlexDisplayObject;
  35.       
  36.       public function ToolTip()
  37.       {
  38.          super();
  39.          mouseEnabled = false;
  40.       }
  41.       
  42.       public function set fontContext(param1:IFlexModuleFactory) : void
  43.       {
  44.          this.moduleFactory = param1;
  45.       }
  46.       
  47.       override public function styleChanged(param1:String) : void
  48.       {
  49.          super.styleChanged(param1);
  50.          if(param1 == "borderStyle" || param1 == "styleName" || param1 == null)
  51.          {
  52.             invalidateDisplayList();
  53.          }
  54.       }
  55.       
  56.       override protected function commitProperties() : void
  57.       {
  58.          var _loc1_:int = 0;
  59.          var _loc2_:TextFormat = null;
  60.          super.commitProperties();
  61.          if(hasFontContextChanged() && textField != null)
  62.          {
  63.             _loc1_ = getChildIndex(DisplayObject(textField));
  64.             removeTextField();
  65.             createTextField(_loc1_);
  66.             invalidateSize();
  67.             textChanged = true;
  68.          }
  69.          if(textChanged)
  70.          {
  71.             _loc2_ = textField.getTextFormat();
  72.             _loc2_.leftMargin = 0;
  73.             _loc2_.rightMargin = 0;
  74.             textField.defaultTextFormat = _loc2_;
  75.             textField.text = _text;
  76.             textChanged = false;
  77.          }
  78.       }
  79.       
  80.       mx_internal function getTextField() : IUITextField
  81.       {
  82.          return textField;
  83.       }
  84.       
  85.       override protected function createChildren() : void
  86.       {
  87.          var _loc1_:Class = null;
  88.          super.createChildren();
  89.          if(!mx_internal::border)
  90.          {
  91.             _loc1_ = getStyle("borderSkin");
  92.             border = new _loc1_();
  93.             if(mx_internal::border is ISimpleStyleClient)
  94.             {
  95.                ISimpleStyleClient(mx_internal::border).styleName = this;
  96.             }
  97.             addChild(DisplayObject(mx_internal::border));
  98.          }
  99.          createTextField(-1);
  100.       }
  101.       
  102.       override protected function measure() : void
  103.       {
  104.          var _loc7_:Number = NaN;
  105.          super.measure();
  106.          var _loc1_:EdgeMetrics = borderMetrics;
  107.          var _loc2_:Number = _loc1_.left + getStyle("paddingLeft");
  108.          var _loc3_:Number = _loc1_.top + getStyle("paddingTop");
  109.          var _loc4_:Number = _loc1_.right + getStyle("paddingRight");
  110.          var _loc5_:Number = _loc1_.bottom + getStyle("paddingBottom");
  111.          var _loc6_:Number = _loc2_ + _loc4_;
  112.          _loc7_ = _loc3_ + _loc5_;
  113.          textField.wordWrap = false;
  114.          if(textField.textWidth + _loc6_ > ToolTip.maxWidth)
  115.          {
  116.             textField.width = ToolTip.maxWidth - _loc6_;
  117.             textField.wordWrap = true;
  118.          }
  119.          measuredWidth = textField.width + _loc6_;
  120.          measuredHeight = textField.height + _loc7_;
  121.       }
  122.       
  123.       public function get fontContext() : IFlexModuleFactory
  124.       {
  125.          return moduleFactory;
  126.       }
  127.       
  128.       public function set text(param1:String) : void
  129.       {
  130.          _text = param1;
  131.          textChanged = true;
  132.          invalidateProperties();
  133.          invalidateSize();
  134.          invalidateDisplayList();
  135.       }
  136.       
  137.       public function get text() : String
  138.       {
  139.          return _text;
  140.       }
  141.       
  142.       mx_internal function removeTextField() : void
  143.       {
  144.          if(textField)
  145.          {
  146.             removeChild(DisplayObject(textField));
  147.             textField = null;
  148.          }
  149.       }
  150.       
  151.       mx_internal function createTextField(param1:int) : void
  152.       {
  153.          if(!textField)
  154.          {
  155.             textField = IUITextField(createInFontContext(UITextField));
  156.             textField.autoSize = TextFieldAutoSize.LEFT;
  157.             textField.mouseEnabled = false;
  158.             textField.multiline = true;
  159.             textField.selectable = false;
  160.             textField.wordWrap = false;
  161.             textField.styleName = this;
  162.             if(param1 == -1)
  163.             {
  164.                addChild(DisplayObject(textField));
  165.             }
  166.             else
  167.             {
  168.                addChildAt(DisplayObject(textField),param1);
  169.             }
  170.          }
  171.       }
  172.       
  173.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  174.       {
  175.          super.updateDisplayList(param1,param2);
  176.          var _loc3_:EdgeMetrics = borderMetrics;
  177.          var _loc4_:Number = _loc3_.left + getStyle("paddingLeft");
  178.          var _loc5_:Number = _loc3_.top + getStyle("paddingTop");
  179.          var _loc6_:Number = _loc3_.right + getStyle("paddingRight");
  180.          var _loc7_:Number = _loc3_.bottom + getStyle("paddingBottom");
  181.          var _loc8_:Number = _loc4_ + _loc6_;
  182.          var _loc9_:Number = _loc5_ + _loc7_;
  183.          mx_internal::border.setActualSize(param1,param2);
  184.          textField.move(_loc4_,_loc5_);
  185.          textField.setActualSize(param1 - _loc8_,param2 - _loc9_);
  186.       }
  187.       
  188.       private function get borderMetrics() : EdgeMetrics
  189.       {
  190.          if(mx_internal::border is IRectangularBorder)
  191.          {
  192.             return IRectangularBorder(mx_internal::border).borderMetrics;
  193.          }
  194.          return EdgeMetrics.EMPTY;
  195.       }
  196.    }
  197. }
  198.